package com.inctech.controller.main;


import javax.annotation.Resource;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.inctech.model.User;
import com.inctech.service.IUserService;

@Controller
@RequestMapping("/main")
public class MainController {
	
	@Resource(name = "userService")
	private IUserService userService;
	
	@RequestMapping("/index")
	public String index(){
		System.out.println(111);
		return "main/index";
	}
	
	@RequestMapping(value="/testAjax",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String testAjax(){
		JSONObject json = new JSONObject();
		json.put("hello", "hello,汤姆!");
		User user = new User();
		user.setNickname("你好吗");
		user.setState(2);
		int flag = userService.insertUser(user);
		json.put("flag", flag);
		return json.toString();		
	}
}
